home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / timer / timer.h < prev   
Encoding:
C/C++ Source or Header  |  1993-07-25  |  1.9 KB  |  96 lines

  1. /*
  2.  * (c) Copyright 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. #ifndef __TIMER_H
  8. #define __TIMER_H
  9.  
  10. /*
  11.  * $Id: timer.h,v 4.2 1993/05/06 06:43:55 panos Exp $
  12.  */
  13.  
  14. #include <sys/time.h>
  15. #include <setjmp.h>
  16.  
  17. /*
  18.  * Return values
  19.  */
  20. #define TIMER_OK            0
  21. #define TIMER_ERR            (-1)
  22.  
  23. /*
  24.  * errno values
  25.  */
  26. #define TIMER_ENOMEM                1
  27. #define TIMER_EBADTYPE            2
  28. #define TIMER_EBADSTATE            3
  29. #define TIMER_EBADTIME            4
  30. #define TIMER_ESIGPROBLEM        5
  31. #define TIMER_ECANTINSERT        6
  32. #define TIMER_ENOTAVAILABLE    7
  33.  
  34. /*
  35.  * flags
  36.  */
  37. #define TIMER_NOFLAGS                0x0
  38. #define TIMER_RETURN_ERROR            0x1
  39. #define TIMER_INC_VAR                0x2
  40. #define TIMER_BLOCK_SAME            0x4
  41. #define TIMER_BLOCK_ALL                0x8
  42. #define TIMER_LONGJMP                0x10
  43.  
  44. enum timer_types { TIMER_REAL, TIMER_VIRTUAL, TIMER_PROF } ;
  45. enum timer_timetypes { TIMER_ABSOLUTE, TIMER_RELATIVE } ;
  46.  
  47. struct timer_action
  48. {
  49.     int        ta_flags ;
  50.     void        (*ta_func)() ;
  51.     void        *ta_arg ;
  52.     jmp_buf    ta_env ;
  53. } ;
  54.  
  55. #ifdef __ARGS
  56. #undef __ARGS
  57. #endif
  58.  
  59. #ifdef PROTOTYPES
  60. #   define __ARGS( s )           s
  61. #else
  62. #   define __ARGS( s )           ()
  63. #endif
  64.  
  65. typedef void *timer_h ;
  66.  
  67. timer_h timer_create        __ARGS( ( 
  68.                                             enum timer_types type,
  69.                                             int flags,
  70.                                             int *errnop
  71.                                         ) ) ;
  72. void timer_destroy         __ARGS( ( timer_h handle ) ) ;
  73.  
  74. int timer_start             __ARGS( (
  75.                                             timer_h handle,
  76.                                             struct itimerval *itvp,
  77.                                             enum timer_times time_type,
  78.                                             struct timer_action *ap 
  79.                                         ) ) ;
  80. void timer_stop             __ARGS( ( timer_h handle ) ) ;
  81.  
  82. void timer_block             __ARGS( ( timer_h handle ) ) ;
  83. void timer_unblock         __ARGS( ( timer_h handle ) ) ;
  84.  
  85. unsigned timer_expirations __ARGS( ( timer_h handle ) ) ;
  86.  
  87. void timer_block_all        __ARGS( ( enum timer_types type ) ) ;
  88. void timer_unblock_all    __ARGS( ( enum timer_types type ) ) ;
  89.  
  90. char *timer_strerr        __ARGS( ( timer_h handle ) ) ;
  91.  
  92. extern int timer_errno ;
  93.  
  94. #endif    /* __TIMER_H */
  95.  
  96.